package com.zxy.ziems.server.controller;

import com.zxy.btp.common.response.JsonResponse;
import com.zxy.btp.common.response.PageResult;
import com.zxy.ziems.server.dto.ChannelEquipQueryDto;
import com.zxy.ziems.server.dto.EquipPointRelDto;
import com.zxy.ziems.server.dto.PointQueryDto;
import com.zxy.ziems.server.service.EquipPointRelService;
import com.zxy.ziems.server.vo.ChannelEquipVo;
import com.zxy.ziems.server.vo.EquipPointRelVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName EquipPointRelController
 * @Description
 * @Author 邓伟
 * @Date 2023/11/30 13:48
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/equipRel")
public class EquipPointRelController {

    @Autowired
    private EquipPointRelService equipPointRelService;

    @PostMapping("/addOrUpdate")
    public JsonResponse addOrUpdate (@RequestBody @Validated EquipPointRelDto equipPointRelDto) {
        equipPointRelService.addOrUpdate(equipPointRelDto);
        return JsonResponse.SUCCESS();
    }

    @GetMapping("/delete")
    public JsonResponse delete (@RequestParam(value = "pointId") String pointId) {
        equipPointRelService.delete(pointId);
        return JsonResponse.SUCCESS();
    }

    @GetMapping("/detail")
    public JsonResponse detail (@RequestParam(value = "pointId") String pointId) {
        EquipPointRelVo equipPointRelVo = equipPointRelService.detail(pointId);
        return JsonResponse.SUCCESS(equipPointRelVo);
    }

    @PostMapping("/page/list")
    public JsonResponse<PageResult<EquipPointRelVo>> pageList (@RequestBody PointQueryDto pointQueryDto) {
        PageResult<EquipPointRelVo> pageResult = equipPointRelService.pageList(pointQueryDto);
        return JsonResponse.SUCCESS(pageResult);
    }
}
